#!/usr/bin/python
NT	=	0 # non-terminal
POS	=	1 # part of speech
WD	=	2 # words

def tos(i):
	if i<0:
		return ""
	else:
		return str(i)

def ttos(l):
	y = []
	for x in l:
		y.append(str(x))
	return ",".join(y)

class TreeNode:
	"Parse Tree Node"

	def __init__(self,i,l,d,t):
		self._id = i
		self._label = l
		self._depth = d
		self._type = t
		self._height	= -1
		self._parent	= -1
		self._child	= -1
		self._brother	= -1
		self._pos	= -1
		self._head = ""
		self._children = []

	def isWD(self):
		return self._type == WD

	def isPOS(self):
		return self._type == POS

	def isNT(self):
		return self._type == NT

	def addChild(self,c):
		self._children.append(c)

	def toSimpleString(self):
		return tos(self._id) + "\t" \
				+ self._label + "\t" \
				+ self._head + "\t" \
				+ tos(self._type) + "\t" \
				+ tos(self._parent) + "\t" \
				+ ttos(self._children) + "\t" \


	def toString(self):
		return tos(self._id) + "\t" \
				+ self._label + "\t" \
				+ tos(self._parent) + "\t" \
				+ tos(self._child) + "\t" \
				+ tos(self._brother) + "\t" \
				+ tos(self._depth) + "\t" \
				+ tos(self._height) + "\t" \
				+ tos(self._type) + "\t" \
				+ tos(self.pos) + "\t" \
				+ ttos(self.children)

